import 'package:BeeApp/MainPage/MainModelPage.dart';
import 'package:BeeApp/MainPage/MainToolPage.dart';
import 'package:BeeApp/MainPage/http_request.dart';
import 'package:BeeApp/MainPage/MainGGModelPage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';

class MainGGNewsPage extends StatefulWidget {
  final String newsID;
  MainGGNewsPage(this.newsID, {Key key}) : super(key: key);

  @override
  _MainGGNewsPageState createState() => _MainGGNewsPageState();
}

class _MainGGNewsPageState extends State<MainGGNewsPage> {
  GGCellModel ggCellModel;
  @override
  void initState() {
    super.initState();
    DioUtils.postHttp(
      context,
      "Usercommon/notice_detail",
      parameters: {
        "token": getData("token"),
        "id": widget.newsID,
      },
      onSuccess: (t) {
        print(t);
        MainModel model = MainModel.fromJson(t);
        if (model.code == 1 && model.data != null) {
          if (mounted) {
            setState(() {
              ggCellModel = GGCellModel.fromJson(t["data"]);
            });
          }
        }
      },
      onError: (error) {
        print(error);
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(context, "公告详情"),
      body: ggCellModel == null
          ? Container()
          : ListView(
              children: [
                Html(data: ggCellModel.content),
              ],
            ),
    );
  }
}
